using UnityEngine;
using UnityEditor;
using System.Collections;
//using System.Collections;

[CustomEditor(typeof(ProcTrees2D))]
public class ProcTrees2DEditor : Editor
{
    ProcTrees2D procTrees;

    public override void OnInspectorGUI()
    {
        procTrees = (ProcTrees2D)target;

        if (GUILayout.Button("Add Seed"))
        {
            GameObject newSeed = Instantiate(Resources.Load("Gizmos/Seed"), Vector3.zero, Quaternion.identity) as GameObject;
            newSeed.transform.name = "Seed";
            newSeed.transform.parent = procTrees.transform;
            newSeed.GetComponent<Seed>().procTrees = procTrees;
            procTrees.seeds.Add(newSeed);
        }

        if (GUILayout.Button("Add Crown"))
        {
            GameObject newCrown = Instantiate(Resources.Load("Gizmos/Crown"), Vector3.up, Quaternion.identity) as GameObject;
            newCrown.transform.name = "Crown";
            newCrown.transform.parent = procTrees.transform;
            newCrown.GetComponent<Crown>().procTrees = procTrees;
            procTrees.crowns.Add(newCrown);
        }

        EditorGUILayout.Space();
        procTrees.runtime = EditorGUILayout.Toggle("Generate at runtime", procTrees.runtime);

        if (procTrees.runtime)
            GUI.enabled = false;
        if (GUILayout.Button("Generate Trees"))
        {
            procTrees.Generate();
        }
        GUI.enabled = true;
    }

    public void CleanUpSeed(int id)
    { 
        
    }
}
